////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// THIS IS NOT ACTUALLY USING MYSQL or SQLITE. /////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
/////// THIS WAS A FILE THAT IS A REDONE AND CLEANER VERSION OF pl_util.lua. NOT FINISHED ///////
////////////////////////////////////////////////////////////////////////////////////////////////


// Quick note: The reason you see alot of ccm in this gamemode, is because I was planning on changing the name before the release, it was to be changed to Community Creative Mod( CCM )
--[[

---------------------------
-- This isn't actually using the SQL library, this is Player data, but I'm cleaning up all my code by A LOT.
---------------------------

// First lets create our two tables we are going to use.

ccm = {} -- Community Creative Mod table
cc = {}  -- Concommand table.

// Okay, the first system we are going to do is names.
// Lets keep everything in order, and we will always do the player meta table functions FIRST, then the concommands.

// Lets start with our base function of checking if a particular data field exists.

local mt = FindMetaTable( "Player" )

function mt:IndexExists(i)
	if ( self:GetPData(tostring(i)) == nil ) then
		return false
	else
		return true
	end
end

// Now lets make some quick functions to transfer NWString
// and NWInt data into PData, so it saves onto the server.

function mt:TransferString( des, str)
	self:SetPData( tostring(des), tostring(self:GetNWString( tostring(str) ) ) )
end

function mt:TransferInteger( des, int )
	self:SetPData( tostring(des), tonumber(self:GetNWString( tostring(str) ) ) )
end

// Now lets override pl:Nick() so we can have RP names.

function mt:Nick()
	return self:GetNWString( "Name" )
end

//////////////////////////////
/////////////////////////////
// Now we are going to make the name system.
////////////////////////////
///////////////////////////

// Make a quick function to update their name from NWString to PData.
function mt:UpdateName()
self:TransferString( "Name", "Name" )
end

// Make a concommand to set their name and update it everytime it's set.
function cc.SetName( pl, cmd, args )
if ( args[1] == nil ) then
	print("CC_SETNAME ERROR: No arguments found(Args[1])!");
end
pl:SetNWString( "Name", args[1] )
pl:UpdateName()
end
concommand.Add( "ccm_setname", cc.SetName )

////////////////////////////
///////////////////////////
// Now we are going to do the currency system.
//////////////////////////
//////////////////////////

// Lets make a function to update it from NWInt to PData.
function mt:UpdateMoney()
self:ConvertInteger( "Money", "Money" )
end

// Lets make a function to set it.
function mt:SetMoney( int )
self:SetNWInt("Money", tonumber(int) )
self:UpdateMoney()
end

// Lets make a function to retrieve the money.
function PMeta:GetMoney()
local r = self:GetPData("Money")
return r
end

// Lets make a function to add money.
function mt:AddMoney( int )
self:SetNWInt("Money", self:GetNWInt("Money") + tonumber(int) )
self:UpdateMoney()
end
--]]